fix: support numpy 2.0 by removing deprecated APIs#3
Open
yasumorishima wants to merge 2 commits intonasa:mainfrom
Open
fix: support numpy 2.0 by removing deprecated APIs#3yasumorishima wants to merge 2 commits intonasa:mainfrom
yasumorishima wants to merge 2 commits intonasa:mainfrom
Conversation
- Replace numpy.distutils.exec_command with subprocess.run (removed in numpy 2.0) - Replace np.NaN with np.nan (removed in numpy 2.0) - Update comment referencing deprecated np.float alias Relates to nasa/Kamodo#154
Address CodeRabbit review: use argument list instead of shell string to prevent command injection. Use cwd parameter instead of cd command. Add shlex for safe argument splitting.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
numpy.distutils.exec_commandwithsubprocess.run(removed in numpy 2.0)np.NaNwithnp.nan(removed in numpy 2.0)np.floataliasshell=Truein subprocess call for security (use argument list +cwdinstead)Relates to nasa/Kamodo#154
Changes
kamodo/util.pynumpy.distutils.exec_command→subprocess.runwith argument list,cwd=folder, noshell=Truekamodo/kamodo.pynp.NaN→np.nankamodo/rpc/proto.pynp.float→numpy floatContext
numpy.distutilswas removed in NumPy 2.0 (migration guide). Theexec_commandfunction has been replaced withsubprocess.runusing an argument list (noshell=True) andshlex.quotefor safe argument handling.A companion PR for
kamodo_ccmc(nasa/Kamodo#156) has also been submitted.